<template>
	<div class="safety_loop_detail alert_detail">
		<header class="top">
			<div class="num"><span v-if="alertDetailData.alertNumber">No.</span>{{alertDetailData.alertNumber}}</div>
		</header>
		<article class="alert_con_one">
			<h3>{{alertDetailData.accidentType}}  {{alertDetailData.responsibility}} {{alertDetailData.bpTypeName}}</h3>
			<p><i class="icon_disk orange_disk ion ion-person"></i>{{alertDetailData.depNames}}</p>
			<p><i class="icon_disk green_disk icon_time"></i>{{alertDetailData.accidentDate}}</p>
			<p><i class="icon_disk blue_disk ion ion-ios-location-outline"></i> {{alertDetailData.city || "未知"}}</p>
		</article>
		<div class="article_con alert_con">
			<article class="con">
				<h4><i class="icon_disk green_disk ion ion-navicon"></i>过程概述</h4>
				<p v-html="alertDetailData.describe || '无'"></p>
			</article>
			<article class="con">
				<h4><i class="icon_disk ion ion-android-alert"></i>事故原因</h4>
				<p v-html="alertDetailData.presentationChannel || '无'"></p>
			</article>
			<article class="con">
				<h4><i class="icon_disk yellow_disk ion ion-android-star-outline"></i>经验教训</h4>
				<p v-html="alertDetailData.lesson || '无'"></p>
			</article>
			<article class="con mb10">
				<h4><i class="icon_disk lightgreen_disk icon_image"></i>相关图片</h4>
				<p><span v-if="imgs"><img v-for="img of imgs" :src="img.attachmentUrl"></span><span v-else>暂无</span></p>
			</article>
		</div>
	</div>
</template>
<script type="text/javascript">
	import getInterface from '../../assets/js/insterface.js'
	import PreviewImg from '../../assets/js/previewImg'

	export default{
		data(){
			return{
				imgs:[],
				alertDetailData:{}
			}
		},
		mixins:[PreviewImg],
		mounted(){
			this.$el.parentElement.parentNode.style.background = '#fafafa';
			document.title="事故Alert";
			this.getAlertData();
			let vue = this;
			setTimeout(()=>{
				vue.readImgInfo();
			},1100)
		},
		methods:{
			getAlertData(){
				const alertDetailUrl = getInterface.getAlertDetailUrl+this.$route.query.id;
				//let param = {id:this.$route.query.id}
				this.$http.get(alertDetailUrl,{emulateJSON: true})
				.then((response) => {
					this.alertDetailData = response.data.resultData;
					this.alertDetailData.accidentDate = this.alertDetailData.accidentDate.substr(0,10).replace(/(\d{4})-(\d{2})-(\d{2})/g,'$1年$2月$3日');
					this.alertDetailData.describe = this.alertDetailData.describe.replace(/\r\n|\n/g,'<br/>');
					this.alertDetailData.presentationChannel = this.alertDetailData.presentationChannel.replace(/\r\n|\n/g,'<br/>');
					this.alertDetailData.lesson = this.alertDetailData.lesson.replace(/\r\n|\n/g,'<br/>');
					this.imgs = response.data.attachmentList;
				})
			}
		}
	}
</script>